plugman: Fix leaking attribute string
authorFelix Riemann <friemann@gnome.org>
Sat, 31 Jan 2015 15:17:24 +0000 (16:17 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 1 Feb 2015 16:06:21 +0000 (11:06 -0500)
https://bugzilla.gnome.org/show_bug.cgi?id=743770

examples/plugman.c

index e9c052a9eb08ca287baceefbe30ca42ab4cd9af6..53f502e3e3d3f3a250c4356dae61dd1b1e3f0ef7 100644 (file)
@@ -267,16 +267,19 @@ disable_plugin (const gchar *name)
   plugin_menu = find_plugin_menu ();
   if (plugin_menu)
     {
-      const gchar *id;
       gint i;
 
       for (i = 0; i < g_menu_model_get_n_items (plugin_menu); i++)
         {
-           if (g_menu_model_get_item_attribute (plugin_menu, i, "id", "s", &id) &&
-               g_strcmp0 (id, name) == 0)
+           gchar *id;
+           if (g_menu_model_get_item_attribute (plugin_menu, i, "id", "s", &id))
              {
-               g_menu_remove (G_MENU (plugin_menu), i);
-               g_print ("Menus of '%s' plugin removed\n", name);
+               if (g_strcmp0 (id, name) == 0)
+                 {
+                   g_menu_remove (G_MENU (plugin_menu), i);
+                   g_print ("Menus of '%s' plugin removed\n", name);
+                 }
+               g_free (id);
              }
         }
     }